package com.example.gcjjhd.agriculture.controller;

import com.example.gcjjhd.agriculture.entity.Alert;
import com.example.gcjjhd.agriculture.service.AlertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/alerts")
@CrossOrigin
public class AlertController {
    @Autowired
    private AlertService alertService;

    @GetMapping
    public List<Alert> getAllActiveAlerts() {
        return alertService.getAllActiveAlerts();
    }

    @PutMapping("/{id}/acknowledge")
    public Alert acknowledgeAlert(@PathVariable Integer id) {
        return alertService.acknowledgeAlert(id);
    }
}